"""
用简洁的方法把二维列表转换成一维列表
例如：
    转换前
        lst = [[1,2,3],[4,5,6]]
    转换后
        lst = [1,2,3,4,5,6]
"""

# 方法一
lst = [[1, 2, 3], [4, 5, 6]]
x = [j for i in lst for j in i]
y = [j for i in lst for j in i if j % 2 == 0]  # 取里面的偶数
print(x, y)

# 方法二
from functools import reduce

lst = [[1, 2, 3], [4, 5, 6]]
x = reduce(lambda x, y: x + y, lst)
print(x)

# 方法三
from itertools import chain  # chain遍历的库

lst = [[1, 2, 3], [4, 5, 6]]
x = list(chain.from_iterable(lst))
print(x)

# 方法四
lst = [[1, 2, 3], [4, 5, 6]]
print(sum(lst, []))
